home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / jmtl028c.zip / JAMTOOL.C < prev    next >
C/C++ Source or Header  |  1994-03-28  |  21KB  |  745 lines

  1.  
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. #include <exec/nodes.h>
  7. #include <exec/types.h>
  8. #include <exec/lists.h>
  9. #include <exec/devices.h>
  10. #include <exec/io.h>
  11. #include <exec/libraries.h>
  12.  
  13. #include <devices/serial.h>
  14.  
  15. #include <dos/var.h>
  16. #include <proto/exec.h>
  17. #include <proto/dos.h>
  18.  
  19. #include "xferq/xferq.h"
  20. #include "xferq/xferq_pragmas.h"
  21.  
  22. char VerString[]="$VER: JamTool 0.28c (94.03.27)";
  23.  
  24. typedef struct entry {
  25.    char address[40];
  26.    char password[20];
  27.    struct entry *next;
  28.    struct entry *prev;
  29. } NODE;
  30.  
  31. NODE *addnew(NODE *start, char *address, char *password);
  32. NODE *search(NODE *start, NODE *temp, char *address);
  33. void delall(NODE *start);
  34.  
  35. int flolist(char uucp);
  36. void writevar(char *stem, char *info);
  37. void readvar(char *name, char *info);
  38. void lookup(struct structup *lookupstruct);
  39. void scanlist(char *list, struct structup *lookupstruct);
  40. void xferqparse(char *source, char *destination);
  41. void dialresp(char *address, char *response);
  42. void chopadds(char *string, char *variable);
  43.  
  44. int type(char *filename, char *device, int unit, unsigned long baud, unsigned char sf);
  45.  
  46.  
  47. int main(int argc, char **argv)
  48. {
  49.  
  50.     FILE *datevar;
  51.  
  52.     static struct structup {
  53.        char found;
  54.        char nodelist[50];
  55.        char address[50];
  56.        char phone[50];
  57.        char sysop[50];
  58.        char type[6];
  59.        char password[20];
  60.        char city[20];
  61.        char flags[30];
  62.        char system[40];
  63.        char baud[10];
  64.        char hub[10];
  65.        char region[10];
  66.        char cost[10];
  67.     } lookupstruct;
  68.  
  69.     int wazoocap, i;
  70.     int error = 0;
  71.     char c;
  72.     char temp[255], tmp[255], stem[30];
  73.  
  74.     char cacheflag, nodeflag, displayflag, variables;
  75.  
  76.     strcpy(lookupstruct.nodelist, "Nodelist:");
  77.     lookupstruct.found=0;
  78.  
  79.     if (argc > 1) argv[1][1] = tolower(argv[1][1]);
  80.  
  81.     if ((argc == 1)||(argv[1][0] != '-')||(argv[1][1] != 'i')&&(argv[1][1] != 'd')
  82.         &&(argv[1][1] != 'v') && (argv[1][1] != 'o') && (argv[1][1] != 'l')
  83.         &&(argv[1][1] != 't') && (argv[1][1] != 's') && (argv[1][1] != 'e')
  84.         &&(argv[1][1] != 'r') && (argv[1][1] != 'i') && (argv[1][1] != 'a'))
  85.     {
  86.        
  87.        printf("\n%s\n\nUsage: %s -command options\n\n", &VerString[6], argv[0]);
  88.        printf("\t%s -a\tline\n", argv[0]);
  89.        printf("\t%s -d\twazoo.cap line\n", argv[0]);
  90.        printf("\t%s -e\tStartTime EndTime env:variable\n", argv[0]);
  91.        printf("\t%s -i\tenv:varname\n", argv[0]);
  92.        printf("\t%s -l{c}{n}{d} Address {stem}\n", argv[0]);
  93.        printf("\t%s -r\tAddress Response\n", argv[0]);
  94.        printf("\t%s -s\t{u}\n", argv[0]);
  95.        printf("\t%s -t\tfilename device unit lockbaud serflags\n", argv[0]);
  96.        printf("\t%s -v\tline\n", argv[0]);
  97.        exit(0);
  98.     }
  99.     if (!(XferqBase = OpenLibrary("xferq.library", 1)))
  100.     {
  101.         printf("Can't Open Libs:Xferq.library v1.0\n");
  102.         exit(0);
  103.     }
  104.  
  105.     switch(argv[1][1])
  106.     {
  107.       case 'a':
  108.       {
  109.  
  110.          FILE *fp;
  111.  
  112.          NODE *start;
  113.          NODE *thisnode;
  114.  
  115.          char *akas, *valid, *invalid, *unknown, *temp;
  116.          char password[20], address[40], passwd[20];
  117.          int i,p, t;
  118.          char junk[50];
  119.  
  120.          if (argc!=3)
  121.          {
  122.             printf("Usage: %s -a line\n", argv[0]);
  123.             printf("\tThis function reads the Env: variable '$(line).remote.password', and it does\n");
  124.             printf("\ta Lookup (phonebook only) of each address in the Env: Variable\n");
  125.             printf("\t'Remote.Addresses', and writes 3 new Env: variables,\n");
  126.             printf("\t'Remote.Addresses.Valid', 'Remote.Addresses.Invalid', and\n");
  127.             printf("\t'Remote.Addresses.Unknown'.  Each variable starts with the\n");
  128.             printf("\tline number you specified in your argument\n");
  129.             CloseLibrary(XferqBase);
  130.             exit(1);
  131.      }
  132.  
  133.          akas=(char *)malloc(2048);
  134.          valid=(char *)malloc(2048);
  135.          invalid=(char *)malloc(2048);
  136.          unknown=(char *)malloc(2048);
  137.          temp=(char *)malloc(512);
  138.  
  139.          start=(struct entry *)malloc(sizeof(struct entry));
  140.          thisnode=(struct entry *)malloc(sizeof(struct entry));
  141.  
  142.  
  143.          start->next = NULL;
  144.          start->prev = NULL;
  145.          strcpy(start->address, "start");
  146.  
  147.          sprintf(temp, "%s.remote.addresses", argv[2]);
  148.          GetVar(temp, akas, 2048, GVF_GLOBAL_ONLY);
  149.  
  150.          sprintf(temp, "%s.remote.password", argv[2]);
  151.          GetVar(temp, password, 20, GVF_GLOBAL_ONLY);
  152.  
  153. #ifdef KDEBUG
  154.          KPrintF("%s\n", akas);
  155. #endif
  156.  
  157.          if ((fp=fopen("s:jamtool.phone", "r")) == NULL)
  158.          {
  159.              strcpy(unknown, akas);
  160.              strcpy(valid, "");
  161.              strcpy(invalid, "");
  162.              goto exitall;
  163.          }
  164.  
  165.          t=0;
  166.          while(fgets(temp, 512, fp)!=NULL)
  167.          {
  168.              t++;
  169.              sscanf(temp, "%s %s %s %s", address, junk, junk, passwd);
  170.              start=addnew(start, address, passwd);
  171.          };
  172.          fclose(fp);
  173.  
  174.          if ((fp=fopen("t:jamtool.cache", "r")) != NULL)
  175.          {
  176.  
  177.             t=0;
  178.             while(fgets(temp, 512, fp)!=NULL)
  179.             {
  180.                t++;
  181.                sscanf(temp, "%s %s %s %s", address, junk, junk, passwd);
  182.                start=addnew(start, address, passwd);
  183.             };
  184.             fclose(fp);
  185.          }
  186.  
  187. #ifdef KDEBUG
  188.          KPrintF("%ld entries read\n", t);
  189. #endif
  190.  
  191.          p=0;
  192.          while(p<strlen(akas))
  193.          {
  194.             i=0;
  195.             while((p<strlen(akas)) && (akas[p] != ' '))
  196.             {
  197.                temp[i]=akas[p];
  198.                p++;
  199.                i++;
  200.         }
  201.             temp[i]=0;
  202. #ifdef KDEBUG
  203.          KPrintF("%s ->", temp);
  204. #endif
  205.  
  206.             xferqparse(temp, address);
  207.  
  208. #ifdef KDEBUG
  209.          KPrintF("%s\n", address);
  210. #endif
  211.  
  212.             thisnode=search(start, thisnode, address);
  213.             strcat(address, " ");
  214.             strcat(thisnode->address, " ");
  215.  
  216.             if (stricmp(thisnode->address, address))
  217.                strcat(unknown, address);
  218.             else if ((!stricmp(thisnode->password, password)) ||
  219.                   (thisnode->password[0] == '-')) 
  220.                strcat(valid, address);
  221.             else
  222.                strcat(invalid, address);
  223.             p++;
  224.      }
  225.  
  226.          delall(start);
  227.  
  228.       exitall:
  229.  
  230.          sprintf(temp, "%s.Remote.Addresses.Valid", argv[2]);
  231.  
  232.          if (strlen(valid) < 255)
  233.             writevar(temp, valid);
  234.          else
  235.             chopadds(valid, temp);
  236.  
  237.          sprintf(temp, "%s.Remote.Addresses.Invalid", argv[2]);
  238.          if (strlen(invalid) < 255)
  239.             writevar(temp, invalid);
  240.          else
  241.             chopadds(invalid, temp);
  242.  
  243.          sprintf(temp, "%s.Remote.Addresses.Unknown", argv[2]);
  244.          if (strlen(unknown) < 255)
  245.             writevar(temp, unknown);
  246.          else
  247.             chopadds(unknown, temp);
  248.  
  249.          free(akas);
  250.          free(valid);
  251.          free(invalid);
  252.          free(unknown);
  253.          free(temp);
  254.          free(thisnode);
  255.          free(start);
  256.  
  257.       }
  258.       break;
  259.  
  260.       case 'l':
  261.       {
  262.          cacheflag = nodeflag = displayflag = variables = 0;
  263.          
  264.          for(i=1;i<strlen(argv[1]); i++)
  265.          {
  266.            c=tolower(argv[1][i]);
  267.            if (c=='c') cacheflag = 1;
  268.            if (c=='n') nodeflag = 1;
  269.            if (c=='d') displayflag = 1;
  270.            if (c=='v') variables = 1;
  271.          }
  272.  
  273.          if ((argc - variables) != 3)
  274.          {
  275.             printf("Usage: %s -l{c}{n}{d}{v} Address {stem}\n\n", argv[0]);
  276.             printf("\tThis command will do a lookup function for the\n");
  277.             printf("\taddress you provide.\n");
  278.             printf("\tc - Turn Cache support on\n");
  279.             printf("\tn - Turn Nodelist support on\n");
  280.             printf("\td - Turn extra display on\n");
  281.             printf("\tv - Turn Env: variables on\n");
  282.             printf("\t{stem} required if Env: variables are enabled\n");
  283.             CloseLibrary(XferqBase);
  284.             exit(5);
  285.          }
  286.  
  287.          readvar("NODELISTDIR", temp);
  288.          if (temp[0]) strcpy(lookupstruct.nodelist, temp);
  289.  
  290.          xferqparse(argv[2], lookupstruct.address);
  291.          for(i=0;lookupstruct.address[i]=toupper(lookupstruct.address[i]);i++);
  292.  
  293.          scanlist("s:jamtool.phone", &lookupstruct);
  294.  
  295.          if (!lookupstruct.found)
  296.          {
  297.             if (cacheflag)
  298.             {
  299.                scanlist("t:jamtool.cache", &lookupstruct);
  300.                if (!lookupstruct.found)
  301.                {
  302.                   if (nodeflag)
  303.                   {
  304.                     lookup(&lookupstruct);
  305.                     if (lookupstruct.found)
  306.                     {
  307.                         sprintf(tmp, "echo >>t:jamtool.cache \"%s %s %s %s %s %s %s\"",
  308.                             lookupstruct.address, lookupstruct.phone,
  309.                             lookupstruct.type, lookupstruct.password,
  310.                             lookupstruct.flags, lookupstruct.city,
  311.                             lookupstruct.sysop);
  312.                         system(tmp);
  313.                     }
  314.                   }
  315.                }
  316.             }
  317.             else
  318.             {
  319.                if (nodeflag)
  320.                  lookup(&lookupstruct);
  321.                
  322.             }                
  323.      }
  324.  
  325.          if (lookupstruct.found)
  326.          {
  327.             if (!strcmp(lookupstruct.sysop, "-")) lookupstruct.sysop[0] = 0;
  328.             if (!strcmp(lookupstruct.city, "-")) lookupstruct.city[0] = 0;
  329.             if (!strcmp(lookupstruct.password, "-")) lookupstruct.password[0] = 0;
  330.  
  331.             if (!strcmp(lookupstruct.phone, "-"))
  332.                   strcpy(lookupstruct.phone, "-Undialable");
  333.  
  334.             printf("Address: %s (%s)\n", lookupstruct.address, lookupstruct.password);
  335.  
  336.             if (lookupstruct.hub[0])
  337.                printf("System : %s\n", lookupstruct.system);
  338.  
  339.             if (displayflag)
  340.                printf("Phone  : %s  Type: %s\n", lookupstruct.phone, lookupstruct.type);
  341.  
  342.             if (lookupstruct.sysop[0])
  343.                printf("Sysop  : %s (%s)\n", lookupstruct.sysop, lookupstruct.city);
  344.  
  345.             printf("Flags  : %s", lookupstruct.flags);
  346.  
  347.             if (lookupstruct.baud[0])
  348.                printf(",%s", lookupstruct.baud);
  349.             printf("\n");
  350.  
  351.             if ((lookupstruct.hub[0]) && displayflag)
  352.             {
  353.                printf("Hub    : %s, Region: %s\n", lookupstruct.hub, lookupstruct.region);
  354.                printf("Cost   : %s\n", lookupstruct.cost);
  355.             }
  356.  
  357.             if (variables)
  358.             {
  359.                sprintf(stem, "%s.Sysop", argv[3]);
  360.                writevar(stem, lookupstruct.sysop);
  361.  
  362.                sprintf(stem, "%s.Address", argv[3]);
  363.                writevar(stem, lookupstruct.address);
  364.  
  365.                sprintf(stem, "%s.Type", argv[3]);
  366.                writevar(stem, lookupstruct.type);
  367.  
  368.                sprintf(stem, "%s.MaxBaud", argv[3]);
  369.                writevar(stem, lookupstruct.baud);
  370.  
  371.                sprintf(stem, "%s.Cost", argv[3]);
  372.                writevar(stem, lookupstruct.cost);
  373.  
  374.                sprintf(stem, "%s.Number", argv[3]);
  375.                writevar(stem, lookupstruct.phone);
  376.  
  377.                sprintf(stem, "%s.Flags", argv[3]);
  378.                writevar(stem, lookupstruct.flags);
  379.  
  380.                if(lookupstruct.password[0]=='-')
  381.                  lookupstruct.password[0]=0;
  382.  
  383.                sprintf(stem, "%s.Password", argv[3]);
  384.                writevar(stem, lookupstruct.password);
  385.  
  386.                sprintf(stem, "%s.City", argv[3]);
  387.                writevar(stem, lookupstruct.city);
  388.  
  389.                sprintf(stem, "%s.SiteName", argv[3]);
  390.                writevar(stem, lookupstruct.system);
  391.         }
  392.  
  393.          }
  394.          else
  395.          {
  396.             printf("Huh?  I don't know this Dude!\n");
  397.             error=1;
  398.          }
  399.       }
  400.       break;
  401.  
  402.     case 'i':
  403.        if (argc != 3)
  404.        {
  405.           printf("Usage: %s -i env:variable\n", argv[0]);
  406.           printf("\tThis function checks the validity of the string in the env:variable\n");
  407.           printf("\tthat you specify.  It checks for special 'control' characters and\n");
  408.           printf("\tother things that you may not want.  It returns WARN (5) if a bad\n");
  409.           printf("\tcharacter is found\n");
  410.           CloseLibrary(XferqBase);
  411.           exit(1);
  412.        }
  413.  
  414.        readvar(argv[2], tmp);
  415.        for (i=0;i<strlen(tmp);i++)
  416.        {
  417.           if ((tmp[i] == '`') || (tmp[i] == '$'))
  418.           {
  419.              CloseLibrary(XferqBase);
  420.              exit(5);
  421.           }
  422.             
  423.           if ((tmp[i] == 34) || (tmp[i] == 39) || (tmp[i] == 96))
  424.           {
  425.              CloseLibrary(XferqBase);
  426.              exit(5);
  427.           }
  428.        }
  429.        break;
  430.  
  431.     case 'r':
  432.        if (argc == 4) dialresp(argv[2], argv[3]);
  433.        else error=1;
  434.        break;
  435.  
  436.     case 's':
  437.        if ((argc != 3) || (argv[2][0]=='u')) 
  438.           flolist(0);
  439.        else
  440.           flolist(1);
  441.        break;
  442.  
  443.     case 'e':
  444.        {
  445.           int hh,mm,ss;
  446.           long start, end, duration;
  447.           if (argc != 5)
  448.           { 
  449.              printf("Usage: %s -e StartTime EndTime Difference\n\n", argv[0]);
  450.              printf("\tBoth StartTime and EndTime are time values specified\n");
  451.              printf("\tin HH:MM:SS format.  An Environment variable named in\n");
  452.              printf("\tthe 3rd value given will have the value of the\n");
  453.              printf("\tdifference between the two.\n");
  454.              CloseLibrary(XferqBase);
  455.              exit(5);
  456.           }
  457.           sscanf(argv[2], "%d:%d:%d", &hh, &mm, &ss);
  458.           start = hh*3600+mm*60+ss;
  459.           sscanf(argv[3], "%d:%d:%d", &hh, &mm, &ss);
  460.           end = hh*3600+mm*60+ss;
  461.           if (end < start) end = end + 86400;
  462.           duration = end - start;
  463.  
  464.           sprintf(tmp, "%02d:%02d:%02d", duration/3600,
  465.           (duration/60)%60, duration%60);
  466.           writevar(argv[4], tmp);
  467.           error = 0;
  468.        }
  469.        break;
  470.  
  471.     case 'd':
  472.        {
  473.           if (argc != 4)
  474.           {
  475.               printf("Usage: %s -d Wazoo.Cap line\n\n", argv[0]);
  476.               printf("\tThis option takes a decimal value and returns an ascii string\n");
  477.               printf("\tin Env:{line}.wazoo.\n");
  478.               error=1;
  479.           }
  480.           else
  481.           {
  482.               strcpy(tmp, "");
  483.               wazoocap = atol(argv[2]);
  484.               if (wazoocap &  8192) strcat(tmp, " 8192");
  485.               if (wazoocap &  4096) strcat(tmp, " 4096");
  486.               if (wazoocap &  2048) strcat(tmp, " 2048");
  487.               if (wazoocap &  1024) strcat(tmp, " 1024");
  488.               if (wazoocap &   256) strcat(tmp, " 256");
  489.               if (wazoocap &   512) strcat(tmp, " 512");
  490.               if (wazoocap &   128) strcat(tmp, " 128");
  491.               if (wazoocap &    64) strcat(tmp, " 64");
  492.               if (wazoocap &    32) strcat(tmp, " Hydra");
  493.               if (wazoocap &    16) strcat(tmp, " Janus");
  494.               if (wazoocap &     8) strcat(tmp, " ZedZap");
  495.               if (wazoocap &     4) strcat(tmp, " ZedZip");
  496.               if (wazoocap &     2) strcat(tmp, " Opus");
  497.               if (wazoocap &     1) strcat(tmp, " DietIFNA");
  498.  
  499.               if (wazoocap & 32768) strcat(tmp, " +Freq");
  500.               if (wazoocap & 16384) strcat(tmp, " +Domain");
  501.               sprintf(temp, "%d.Wazoo", atoi(argv[3])); 
  502.               writevar(temp, tmp);
  503.               error = 0;
  504.           }
  505.           break;
  506.        }
  507.  
  508.      case 't':
  509.        {
  510.           if (argc != 7)
  511.           {
  512.               printf("Usage: %s -t filename device unit baud serflags\n\n", argv[0]);
  513.               printf("\tThis option types a single out the modem\n");
  514.               error = 1;
  515.           }
  516.           else
  517.           {
  518.               type(argv[2], argv[3], atoi(argv[4]), (unsigned) atol(argv[5]),
  519.                  (unsigned char) atoi(argv[6]));
  520.           }
  521.           break;
  522.  
  523.        }
  524.  
  525.      case 'v':
  526.        {
  527.           if (argc != 3)
  528.           {
  529.               printf("Usage: %s -v [line]\n\n", argv[0]);
  530.               printf("\tThis option takes a single parameter of the line number, and\n");
  531.               printf("\tcreates two env: variables, {line}.version and {line}.date.\n");
  532.               error = 1;
  533.           }
  534.           else
  535.           {
  536.               sprintf(temp,"date >env:%s.Date", argv[2]);
  537.               system(temp);
  538.               sprintf(temp,"env:%s.Date", argv[2]);
  539.               datevar = fopen(temp, "r");
  540.               fgets(tmp, 80, datevar);
  541.               fclose(datevar);
  542.               tmp[strlen(tmp)-10] = 0;
  543.               datevar = fopen(temp, "w");
  544.               fputs(tmp, datevar);
  545.               fclose(datevar);
  546.               sprintf(temp,"version >env:%s.Version", argv[2]);
  547.               system(temp);
  548.               sprintf(temp,"env:%s.Version", argv[2]);
  549.               datevar = fopen(temp, "r");
  550.               fgets(tmp, 80, datevar);
  551.               fclose(datevar);
  552.               tmp[strlen(tmp)-1] = 0;
  553.               datevar = fopen(temp, "w");
  554.               fputs(tmp, datevar);
  555.               fclose(datevar);
  556.               error = 0;
  557.           }
  558.           CloseLibrary(XferqBase);
  559.           exit(error);
  560.           break;
  561.        }
  562.    
  563.     }
  564.     CloseLibrary(XferqBase);
  565.     return(error);
  566. }
  567.  
  568.  
  569.  
  570.  
  571.  
  572. void writevar(char *name, char *info)
  573. {
  574.    SetVar(name, info, -1, GVF_GLOBAL_ONLY);
  575. }
  576.  
  577.  
  578. void readvar(char *name, char *info)
  579. {
  580.    int l;
  581.    l=GetVar(name, info, 10, GVF_GLOBAL_ONLY);
  582.  
  583.    if (l<1)
  584.       info[0]=0;
  585.  
  586. }
  587.  
  588.  
  589. NODE *addnew(NODE *start, char *address, char *password)
  590. {
  591.     NODE *new=NULL;
  592.     NODE *temp;
  593.  
  594.     if ((new=(NODE *)malloc(sizeof(NODE))) != NULL)
  595.     {
  596.         strcpy(new->address, address);
  597.         strcpy(new->password, password);
  598.         
  599.         temp=start;
  600.         if (temp->next != NULL) temp=temp->next;
  601.  
  602.         while((temp->next != NULL) && (strcmp(temp->address, new->address) < 0))
  603.            temp=temp->next;
  604.  
  605.         if (temp->next == NULL)
  606.         {
  607.            temp->next = new;
  608.            new->prev = temp;
  609.            new->next = NULL;
  610.         }
  611.         else if (temp==start)
  612.         {
  613.            new->prev=NULL;
  614.            new->next=temp;
  615.            start->prev=new;
  616.            start=new;
  617.         }
  618.         else
  619.         {
  620.            temp=temp->prev;
  621.            new->next=temp->next;
  622.            temp->next=new;
  623.            new->prev=temp;
  624.            new->next->prev=new;
  625.     }
  626.  
  627. #ifdef KDEBUG
  628.          KPrintF("Added: %s -> %ld\n", new->address, new->address);
  629. #endif
  630.     }
  631.     return (start);
  632. }
  633.         
  634. NODE *search(NODE *start, NODE *temp, char *address)
  635. {
  636.     temp=start;
  637.  
  638. #ifdef KDEBUG
  639.          KPrintF("\nSearching for: %s\n", address);
  640. #endif
  641.  
  642.     while((temp->next != NULL) && (stricmp(address, temp->address)))
  643.     {
  644. #ifdef KDEBUG
  645.        KPrintF("%s -> %ld\n", temp->address, stricmp(address, temp->address));
  646. #endif
  647.        temp=temp->next;
  648.     }
  649.  
  650.     return temp;
  651. }
  652.  
  653. void delall(NODE *start)
  654. {
  655.  
  656.    NODE *temp;
  657.  
  658.    temp=start->next;
  659.  
  660.    while(temp->next != NULL)
  661.    {
  662.       temp=temp->next;
  663.  
  664. #ifdef KDEBUG
  665.          KPrintF("Deleting: %s -> %ld\n", temp->prev->address, temp->prev);
  666. #endif
  667.       free(temp->prev);
  668.    }
  669.  
  670. #ifdef KDEBUG
  671.          KPrintF("Deleting: %s -> %ld\n", temp->address, temp);
  672. #endif
  673.    free(temp);
  674. }
  675.  
  676. void chopadds(char *string, char *variable)
  677. {
  678.    char info[300], name[255];
  679.    int i;                     /* counter in string */
  680.    int j;                     /* counter in info */
  681.    int k;                     /* number of variables */
  682.  
  683.  
  684. #ifdef KDEBUG
  685.    KPrintF("%s -> %s\n", variable, string);
  686. #endif
  687.  
  688.    i=0;k=0;
  689.    while(string[i])
  690.    {
  691.       j=0;
  692.  
  693.       do
  694.       {
  695.          info[j++]=string[i++];
  696.       } while ((j<200) && (string[i]));
  697.  
  698.       if (string[i])
  699.       {
  700.          do
  701.          {
  702.             info[j++]=string[i++];
  703.          } while ((string[i]) && (string[i] != ' '));
  704.       }
  705.  
  706.       info[j]=0;
  707.       if (string[i]) i++;
  708.  
  709.       if (k)
  710.          sprintf(name, "%s.%d", variable, k+1);
  711.       else
  712.          strcpy(name, variable);
  713.       SetVar(name, info, -1, GVF_GLOBAL_ONLY);
  714.  
  715. #ifdef KDEBUG
  716.    KPrintF("%s -> %s\n", name, info);
  717. #endif
  718.  
  719.       k++;
  720.    }
  721. }
  722.  
  723. void xferqparse(char *source, char *destination)
  724. {
  725.     char *address=NULL;
  726.  
  727.     struct NetAddress *addr;
  728.  
  729.     if(addr=XfqGetAddressTags(source,NULL,XQ_Mandatory,XQADDR_NODE,
  730.                   XQ_Optional,XQADDR_ANYTHING,TAG_DONE))
  731.     {
  732.        if(address=XfqPutAddressTags(addr, XQ_Mandatory,XQADDR_ANYTHING,
  733.                    XQ_Optional,XQADDR_ANYTHING,TAG_DONE))
  734.        {
  735.            strcpy(destination, address);
  736.            XfqDropObject(address);
  737.            XfqDropObject(addr);
  738.        }
  739.     }
  740.     else
  741.        strcpy(destination, source);
  742.  
  743.     return;
  744. }
  745.